#!/bin/bash
##################################
#                                #
# Firefox 3 bookmark validator   #
#                                #
# Usage:                         #
# Edit the profile variable      #
# and then run firebookmarks.sh  #
# Note:                          #
# urlchecker.py is also a        #
# standalone python script which #
# should be run by giving the    #
# location of places.sqlite as   #
# an option                      #
#                                #
##################################
profile=firefox3
base=$HOME/.mozilla/firefox
sql="select moz_places.url from moz_places inner join moz_bookmarks on moz_places.id=moz_bookmarks.fk where moz_bookmarks.type=1 and moz_places.url like 'http%';"
if [ -e $base/profiles.ini ]
then
	temp=$(grep -E "Path=(\w+\.$profile)" $HOME/.mozilla/firefox/profiles.ini)
	db=$base/${temp:5}/places.sqlite
	if [[ -e $db && !($(pgrep firefox | wc -c) -gt 0) ]]; then
		urlchecker.py $db
	else
		newfile=tempfile
		cp $db $newfile
		urlchecker.py $newfile
		rm $newfile
	fi
fi
